package com.zw.knowlege.controller;


import com.alibaba.fastjson.JSONObject;
import com.zw.common.annotation.InterfaceAttribute;
import com.zw.common.constant.InterfaceNameConstants;
import com.zw.common.constant.NumberConst;
import com.zw.common.response.ResponseResult;
import com.zw.knowlege.annotation.ParamCheckJson;
import com.zw.knowlege.common.StaticValue;
import com.zw.knowlege.pojo.ExperiencePojo;
import com.zw.knowlege.service.ExperienceBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author xtyu
 * @Date 2022/5/9
 * @description 经验基础信息处理的Controller
 */
@RestController
@RequestMapping("/experiencebase")
public class ExperienceProcessController {

    @Autowired
    private ExperienceBaseService experienceBaseService;

    /**
     * 新建经验
     * @param paramJson
     * @return
     */
    @PostMapping("/addExpreience")
    @InterfaceAttribute(name = InterfaceNameConstants.KNOWLEGE_EXPERIENCE_NEW, operateType = "1", module = "7")
    @ParamCheckJson(args = {StaticValue.EXPERIENCE_TITLE, StaticValue.EXPERIENCE_USERINFO, StaticValue.EXPERIENCE_CLASSINFO, StaticValue.EXPERIENCE_DEPTTYPE})
    public ResponseResult addNewExpreience(@RequestBody JSONObject paramJson){
        return experienceBaseService.insertExperienceBase(paramJson, null);
    }

    /**
     * 编辑经验
     * @param paramJson
     * @return
     */
    @PostMapping("/editExperience")
    @InterfaceAttribute(name = InterfaceNameConstants.KNOWLEGE_EXPERIENCE_EDIT, operateType = "3", module = "7")
    @ParamCheckJson(args = {StaticValue.EXPERIENCE_TITLE, StaticValue.EXPERIENCE_USERINFO, StaticValue.EXPERIENCE_CLASSINFO, StaticValue.EXPERIENCE_DEPTTYPE})
    public ResponseResult editExperience(@RequestBody JSONObject paramJson){
        return experienceBaseService.exitExperienceBase(paramJson);
    }

    /**
     * 状态变更
     * @param paramJson
     * @return
     */
    @PostMapping("/statusChange")
    @InterfaceAttribute(name = InterfaceNameConstants.KNOWLEGE_EXPERIENCE_STATUSCHANGE, operateType = "3", module = "7")
    @ParamCheckJson(args = {StaticValue.EXPERIENCE_ID, StaticValue.EXPERIENCE_ACTION})
    public ResponseResult statusChange(@RequestBody JSONObject paramJson) {
        return experienceBaseService.updateExperienceStatus(paramJson);
    }
}
